package com.wardrobe.soa.api.agreement;


import com.wardrobe.domain.agreement.AgreementShowBean;
import com.wardrobe.soa.common.ApiResult;
import com.wardrobe.soa.utils.CommonConsant;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by Administrator on 2018/11/7.
 */
@RestController
@RequestMapping("/api/agreement")
public class AgreementController {
    private static final Logger logger = LoggerFactory.getLogger(AgreementController.class);

    @Autowired
    private AgreementService agreementService;

    @RequestMapping("/getAgreementByType")
    public ApiResult getAgreementByType(int type){
        try {
            if(type==0){
                return new ApiResult(CommonConsant.successCode,CommonConsant.success,CommonConsant.successMsg,"");
            }
            AgreementShowBean agreementByType = agreementService.getAgreementByType(type);
            if (agreementByType!=null){
                return new ApiResult(CommonConsant.successCode,CommonConsant.success,CommonConsant.successMsg,agreementByType.getContent());

            }else{
                return new ApiResult(CommonConsant.successCode,CommonConsant.success,CommonConsant.successMsg,"");
            }
        }catch (Exception e){
            logger.error("getAgreementByType error",e);
        }
        return new ApiResult(CommonConsant.serverFailedCode,CommonConsant.failed,CommonConsant.serverFailedMsg,"");
    }
}
